/**
*	打开证件采集
*/
function papersClick(){
	if(IsIE()){
		EScanner.SetVideoAngle(papersCurrent);
		EScanner.StartVideo();
	}else{
		if (typeof currentStream !== 'undefined') {
		  stopMediaTracks(currentStream);
		}
		var videoConstraints = {};

		if (papersSelect.value === '') {
			videoConstraints.facingMode = 'environment';
		} else {
			videoConstraints.deviceId = { exact: papersSelect.value };
		}
		const constraints = {
		  video: videoConstraints,
		  audio: false
		};
		
		navigator.mediaDevices
		.getUserMedia(constraints)
		.then(stream => {
			currentStream = stream;
			papersVideo.srcObject = stream;
			return navigator.mediaDevices.enumerateDevices();
		})

	.catch(error => {
	  console.error(error);
	});
	}
}
/**
*	证件拍照
*/
function papersCameClick() {
  //获得Canvas对象
  let video = document.getElementById("papersVideo");
  let canvas = document.getElementById("papersImg");
  let ctx = canvas.getContext('2d');
  ctx.drawImage(video, 0, 0, 348, 261);
  canvas.style.transform = 'rotate('+papersCurrent+'deg)';
  
}

var papersCurrent =0;
function papersRotateLeft(){
	papersCurrent = (papersCurrent-90)%360;
	var papersVideo = document.getElementById("papersVideo");
	papersVideo.style.transform = 'rotate('+papersCurrent+'deg)';
}
function papersRotateRight(){
	papersCurrent = (papersCurrent+90)%360;
	var papersVideo = document.getElementById("papersVideo");
	papersVideo.style.transform = 'rotate('+papersCurrent+'deg)';
}
